/*
 * @Author: ziqi jhzq12345678
 * @Date: 2024-08-24 10:51:11
 * @LastEditors: wangdazhuang
 * @LastEditTime: 2025-01-25 13:39:13
 * @FilePath: /pornhub_app/lib/routes/routes.dart
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import 'package:get/get.dart';
import 'package:pornhub_app/components/easy_toast.dart';
import 'package:pornhub_app/model/choice/choice_models.dart';
import 'package:pornhub_app/model/station_model.dart';
import 'package:pornhub_app/services/app_service.dart';
import 'package:pornhub_app/utils/enum.dart';
import 'package:pornhub_app/views/ai/controllers/ai_home_page_controller.dart';

import '../model/video_base_model.dart';
import '../views/player/controllers/video_play_controller.dart';

abstract class Routes {
  Routes._();

  static const no_net_work = '/no_net_work';
  static const noSignal = '/no_signal';
  static const _mainPrefix = '/home';
  static const main = '$_mainPrefix/:tab';

  // arround_tab

  static const arround = '/arround';
  static const arroundDetail = '/arround/detail';
  static const arroundFans = '/arround/fans';
  static const arroundFansRule = '/arround/fans/rule';

  static const stationDetailSorting = '/station/detail/sorting';
  static const stationDetailRanking = '/station/detail/ranking';
  static const contentWh = '/content/wh';
  static const choiceDetail = '/choice/detail';
  static const bloggerCollectionDetail = '/bloggerCollectionDetail';

  static const videoBox = '/videobox';

  static const launch = '/launch';
  static const videoplay = '/videoplay';
  static const portrayPlay = '/portray/play';
  static const search = '/search';
  static const searchresult = '/searchresult';
  static const searchuserresult = '/searchuserresult';
  static const videotag = '/videotag';
  static const tagvideos = '/tagvideos';
  static const tag_videos = '/tag_videos';
  static const producer = '/producer';
  static const creatorlist = '/creatorlist';
  static const starlist = '/starlist';
  static const vip = '/vip';
  static const recharge = '/recharge';
  static const vipRecord = '/vipRecord';
  static const rechargeRecord = '/rechargeRecord';
  static const withdraw = '/withdraw';
  static const share = '/share'; //我的分享
  static const shareRecord = '/shareRecord';
  static const annews = '/annews';
  static const commonplayer = '/commonplayer';
  static const webview = '/webview';

  static const loginregist = '/loginregist';

  ///媒体查看器
  static const mediaviewer = '/mediaviewer';

  static const minebuy = '/mine/minebuy';
  static const download = '/download';
  static const addlitevideos = '/addlitevideos';
  static const choosetags = "/choosetags";
  static const addliteVideoRule = "/addliteVideoRule";

  ///mine
  static const accountcredentials = '/mine/accountcredentials';
  static const profitmain = "/profitmain";
  static const editusername = '/mine/editusername';
  static const edituserintroduction = '/mine/edituserintroduction';
  static const settingaccountpwd = '/mine/settingaccountpwd';
  static const edituserinfo = '/mine/edituserinfo';
  static const imageviewer = '/imageviewer';
  static const rechargehint = '/rechargehint';
  static const retrieveaccount = '/mine/retrieveaccount';
  static const scannercode = '/mine/scannercode';
  static const exchangevippage = '/mine/exchangevippage';
  static const invitecodepage = '/mine/invitecodepage';
  static const settingpage = '/mine/settingpage';
  static const my_publications = '/mine/my_publications';
  static const my_publications_local_drafts =
      '/mine/my_publications/local_drafts';
  static const favorite = '/mine/favorite';
  static const watch = '/mine/watch';
  static const buy = '/mine/buy';
  static const attention = '/mine/attention';
  static const service = '/mine/service';
  static const setpassword = '/mine/setpassword';
  static const openpasswordpage = '/mine/openpasswordpage';
  static const changedesktoppage = '/mine/changedesktoppage';
  static const groupbuymemberspage = '/mine/groupbuymemberspage';
  static const groupbuymemberssuccesspage = '/mine/groupbuymemberssuccesspage';

  static const mine_fans_followers = '/mine/fans_followers';
  static const mine_new_followers = '/mine/new_followers';
  static const minesystemavator = '/mine/systemavator';
  static const minesincomedynmaic = '/mine/minesincomedynmaic';
  static const minesincomevideo = '/mine/minesincomevideo';
  static const minesrelease = '/mine/minesrelease';
  static const minepromotion = '/mine/minepromotion';
  static const minemessage = '/mine/minemessage';

  static const mine_vip_exchange = "/mine/vip_exchange";

  static const mine_user_home = "/mine/user_home";

  ///community

  static const communityDetail = '/community/detail';
  static const communityPublish = '/community/publish';

  ///engagement
  static const engagementDetail = '/engagement/engagementDetail';
  static const engagementStationMorePage =
      '/engagement/engagementStationMorePage';
  static const engagement_search = '/engagement/search';
  static const engagement_search_result = '/engagement/search/result';

  /// ai
  static const _aiPrefix = '/ai';
  static const _aiHomePrefix = '$_aiPrefix/home';
  static const aiHome = '$_aiHomePrefix/:tab';
  static const aiRecord = '$_aiPrefix/record';
  static const aiEntry = '$_aiPrefix/entry';

  static const shortvideoplayer = '/shortvideoplayer';

  static const welfare = '/welfare';

  static const adultGameStrategy = '/adult/game/strategy';

  static const adultGameListByCollection = '/adult/game/list/by/collection';

  static const adultGameDetail = '/adult/game/detail';

  static const adultGameSearchResult = '/adult/game/search/result';

  static const audltGameSearchHot = '/audlt/game/search/hot';

  //comics
  static const bookshelf = '/bookshelf';

  // 抖音
  static const douYin = '/douyin';
  static const rainbowHot = '/rainbowHot';

  // 播单详情
  static const playlistDetail = '/playlistDetail';

  ///活动
  static const activity = '/activity';
  static const activityMy = '/activity/my';
  static const activityDetail = '/activity/details';
  static const activityPlayer = '/activity/player';

  /// product
// static const productDetail = '/product/detail';

  /// resource
// static const resourceDetail = '/resource/detail';
}

// 带参页面，统一写到这里
extension ToNamedWithParamsGet on GetInterface {
  offHome([MainTabName tab = MainTabNameEnum.home]) =>
      offNamed('${Routes._mainPrefix}/$tab');

  toPlayVideo({required int videoId}) {
    if (Get.isRegistered<VideoPlayController>()) {
      final vc = Get.find<VideoPlayController>();
      vc.getVideoById(videoId);
      until(
          (route) => (route.settings.name ?? '').startsWith(Routes.videoplay));
      return;
    }
    toNamed(
      Routes.videoplay,
      parameters: {
        'id': videoId.toString(),
      },
    );
  }

  toPortrayPlay({required int portrayPicId}) => toNamed(
        Routes.portrayPlay,
        parameters: {
          'portrayPicId': portrayPicId.toString(),
        },
      );

  toComonVideoPlay({required String url, double? asp}) =>
      toNamed(Routes.commonplayer,
          arguments: url,
          parameters: asp != null ? {'asp': asp.toString()} : null);

  toStationDetail(StationModel station) {
    if (station.detailStyle == StationDetailStyle.rank) {
      toNamed(
        Routes.stationDetailRanking,
        arguments: {'station': station},
      );
    } else {
      toNamed(
        Routes.stationDetailSorting,
        arguments: {'station': station},
      );
    }
  }

  toChoiceDetail(VideoChoiceModel choice) =>
      toNamed(Routes.choiceDetail, arguments: {'choice': choice});

  toBloggerCollectionDetail(int collectionId) =>
      toNamed(Routes.bloggerCollectionDetail,
          arguments: {'collectionId': collectionId});

  toAiHome([AiTabName? tab]) {
    if (Get.find<AppService>().aiEntrance.isMaintain) {
      EasyToast.show('AI 正在维护中...');
      return;
    }
    if (Get.currentRoute.startsWith(Routes._aiHomePrefix)) {
      Get.find<AiHomePageController>().changeToIndexByTabName(tab);
    } else {
      toNamed('${Routes._aiHomePrefix}/${tab ?? AiTabNameEnum.index}');
    }
  }

  toImageViewer(List<String> images, {int? currentIndex}) => toNamed(
        Routes.imageviewer,
        arguments: images,
        parameters: currentIndex != null
            ? {
                "index": currentIndex.toString(),
              }
            : {},
      );

  toShortVideoPlay(List<VideoBaseModel> items, {required int idx}) => toNamed(
        Routes.shortvideoplayer,
        arguments: {'videos': items, 'idx': idx},
      );

  toMediaViewer({
    required List<String> images,
    String? playPath,
    String? extraInfo,
  }) =>
      toNamed(Routes.mediaviewer, arguments: {
        "images": images,
        "video": playPath
      }, parameters: {
        'extra': extraInfo ?? '',
      });

  toTagVideos({required List<String> tagId, required String tagName}) =>
      toNamed(Routes.tag_videos,
          arguments: {'tagId': tagId, 'tagName': tagName});

// toProductDetail({required int id}) => toNamed(
//       Routes.productDetail,
//       parameters: {'id': id.toString()},
//     );

// toResourceDetail({required int id}) => toNamed(
//       Routes.resourceDetail,
//       parameters: {'id': id.toString()},
//     );

  toCommunityDetail({required int dynamicId, dynamicModel}) => toNamed(
        Routes.communityDetail,
        arguments: {
          'dynamicId': dynamicId,
          'dynamicModel': dynamicModel,
        },
      );

  toEngagementDetail({required int meetUserId}) => toNamed(
        Routes.engagementDetail,
        parameters: {
          'meetUserId': '$meetUserId',
        },
      );

  toEngagementStationMore(
          {required int stationId, required String stationName}) =>
      toNamed(
        Routes.engagementStationMorePage,
        parameters: {
          'stationId': '$stationId',
          'stationName': stationName,
        },
      );

  toGameDetail(int id) => toNamed(
        Routes.adultGameDetail,
        parameters: {
          "id": id.toString(),
        },
      );

  toAdultGameSearchResultByWord(String word) => toNamed(
        Routes.adultGameSearchResult,
        parameters: {
          "word": word,
        },
      );

  toAdultGameSearchResultByWordReplace(String word) => offNamed(
        Routes.adultGameSearchResult,
        parameters: {
          "word": word,
        },
      );

  toPlaylistDetail(int playlistId) =>
      toNamed(Routes.playlistDetail, arguments: {'playlistId': playlistId});

  toShare({int tabIndex = 0}) =>
      toNamed(Routes.share, arguments: {'tabIndex': tabIndex});

  ///充值记录
  ///[type] 2:vip  3:金币
  toRechargeRecord({required int type}) =>
      toNamed(Routes.rechargeRecord, arguments: {'type': type});

  toActivityDetail(int activityId) =>
      toNamed(Routes.activityDetail, arguments: {'activityId': activityId});

  toIncomeDynamicDetail({int dynamicId = 0}) =>
      toNamed(Routes.minesincomedynmaic, arguments: {'dynamicId': dynamicId});

  toIncomeVideoDetail({int videoId = 0, int videoMark = 0}) =>
      toNamed(Routes.minesincomevideo, arguments: {
        'videoId': videoId,
        'videoMark': videoMark,
      });

  ///去会员界面
  ///[tabInitIndex]0 会员  1 金币
  toVip({int tabInitIndex = 0}) =>
      toNamed(Routes.vip, arguments: {'tabInitIndex': tabInitIndex});

  ///去提现界面
  ///[title]0 余额提现  1 金币提现
  toWithdraw({required String title}) =>
      toNamed(Routes.withdraw, arguments: {'title': title});

  toUserHome({required int userId}) =>
      toNamed(Routes.mine_user_home, arguments: {'userId': userId});
// toArroundDetail({
//   int userId = 0,
// }) =>
//     toNamed(Routes.arroundDetail, arguments: {
//       'id': userId,
//     });
}
